home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / PIL / ImtImagePlugin.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  2KB  |  59 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. __version__ = '0.2'
  5. import string
  6. import re
  7. import Image
  8. import ImageFile
  9. field = re.compile('([a-z]*) ([^ \\r\\n]*)')
  10.  
  11. class ImtImageFile(ImageFile.ImageFile):
  12.     format = 'IMT'
  13.     format_description = 'IM Tools'
  14.     
  15.     def _open(self):
  16.         if '\n' not in self.fp.read(100):
  17.             raise SyntaxError, 'not an IM file'
  18.         
  19.         self.fp.seek(0)
  20.         xsize = ysize = 0
  21.         while None:
  22.             s = self.fp.read(1)
  23.             if not s:
  24.                 break
  25.             
  26.             if s == chr(12):
  27.                 self.tile = [
  28.                     ('raw', (0, 0) + self.size, self.fp.tell(), (self.mode, 0, 1))]
  29.                 break
  30.                 continue
  31.             s = s + self.fp.readline()
  32.             if len(s) == 1 or len(s) > 100:
  33.                 break
  34.             
  35.             if s[0] == '*':
  36.                 continue
  37.             
  38.             m = field.match(s)
  39.             if not m:
  40.                 break
  41.             
  42.             (k, v) = m.group(1, 2)
  43.             if k == 'width':
  44.                 xsize = int(v)
  45.                 self.size = (xsize, ysize)
  46.                 continue
  47.             if k == 'height':
  48.                 ysize = int(v)
  49.                 self.size = (xsize, ysize)
  50.                 continue
  51.             if k == 'pixel' and v == 'n8':
  52.                 self.mode = 'L'
  53.                 continue
  54.             continue
  55.             return None
  56.  
  57.  
  58. Image.register_open('IMT', ImtImageFile)
  59.